package com.vrv.common;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.vrv.netmgr.R;

public class UpdateProgress {
	//
	private Dialog updateProgress;
	public ProgressBar progressBar;
	private TextView percent;
	//
	public UpdateProgress(Context context) {
		//
		updateProgress = new Dialog(context);
		updateProgress.requestWindowFeature(Window.FEATURE_NO_TITLE);
		//
		Window window = updateProgress.getWindow();
		WindowManager.LayoutParams layoutParams = window.getAttributes();
		layoutParams.width = 200;
		window.setAttributes(layoutParams);
		//
		View layout = LayoutInflater.from(context).inflate(R.layout.view_progress_dialog, null);
		progressBar = (ProgressBar) layout.findViewById(R.id.update_progress);
		percent = (TextView) layout.findViewById(R.id.update_percent);
		updateProgress.setContentView(layout);
		updateProgress.show();
	}
	//定义一些操作dialog的方法
	public void dismiss() {
		updateProgress.dismiss();
	}
	public void cancel(){
		updateProgress.cancel();
	}
	//添加进度显示
	public void setText(String s){
		percent.setText(s);
	}
	//定义一些操作progress的方法
	public void setMax(int i){
		progressBar.setMax(i);
	}
}
